package org.wzy.xmlg_backend.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.wzy.xmlg_backend.entity.Result;
import org.wzy.xmlg_backend.service.IStudentStatisticsService;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/students/statistics")
@Tag(name = "StudentStatisticsController", description = "学员统计接口")
public class StudentStatisticsController {

    @Autowired
    private IStudentStatisticsService statisticsService;

    @GetMapping("/gender")
    @Operation(summary = "按性别统计")
    public Result<Map<String, Long>> genderStats() {
        return Result.success(statisticsService.countByGender());
    }

    @GetMapping("/class")
    @Operation(summary = "按班级统计")
    public Result<List<Map<String, Object>>> classStats() {
        return Result.success(statisticsService.countByClass());
    }

    @GetMapping("/status")
    @Operation(summary = "按状态统计")
    public Result<Map<String, Long>> statusStats() {
        return Result.success(statisticsService.countByStatus());
    }

    @GetMapping("/location")
    @Operation(summary = "按地理位置统计")
    public Result<List<Map<String, Object>>> locationStats() {
        return Result.success(statisticsService.countByLocation());
    }
}